package org.phalanx.game.units;

import java.util.HashMap;

public class PhalanxMapUnitSet {
	private HashMap<String,PhalanxMapUnit> unitTable;

	public PhalanxMapUnitSet(){
		unitTable = new HashMap<String, PhalanxMapUnit>();
	}

	public void addPhalanxMapUnit(PhalanxMapUnit mapUnit){
		if (mapUnit != null && !unitTable.containsValue(mapUnit)){
			unitTable.put(mapUnit.getUnitName(), mapUnit);
		}
	}

	public void removePhalanxMapUnit(PhalanxMapUnit mapUnit){
		if (mapUnit != null && unitTable.containsValue(mapUnit)){
			unitTable.remove(mapUnit);
		}
	}
	
	public PhalanxMapUnit getMapUnit(String refName){
		PhalanxMapUnit unit = null;
		
		if (unitTable.containsKey(refName)){
			unit = unitTable.get(refName);
		}
		
		return unit;
	}
	
	public boolean hasUnit(PhalanxMapUnit unit){
		return unitTable.containsValue(unit);
	}
}
